package com.ss.android.usergrowth;

import android.content.Context;
import android.net.Uri;

import inline.FileUtils;

public final class b {
    private static volatile String a;
    private static String b;

    static {
        a = "snssdk143";
    }

    public static String a(Context arg4, String arg5) {
        int v0;
        StringBuilder v2 = new StringBuilder(arg5);
        if (v2.indexOf("#") > 0) {
            v0 = 0;
        } else {
            String v0_1 = b != null ? b : a(arg4.getPackageCodePath());
            if (v0_1.length() == 0) {
                v0 = 0;
            } else {
                String v1 = v2.indexOf("?") > 0 ? "&" : "?";
                v2.append(v1).append(v0_1);
                v0 = 1;
            }
        }

        if (v0 != 0) {
            arg5 = v2.toString();
        }

        return arg5;
    }

    private static String a(String arg4) {
        String v0_1;
        Class v1 = b.class;
        synchronized (v1) {
            if (b == null) {
                try {
                    v0_1 = FileUtils.d(arg4);
                    if (v0_1 != null) {
                        if ((v0_1.startsWith("growth")) || (v0_1.startsWith(a))) {
                            Uri v0_2 = Uri.parse(v0_1);
                            if ("growth".equals(v0_2.getScheme())) {
                                b = v0_2.getQuery();
                            } else {
                                if (a.equals(v0_2.getScheme())) {
                                    b = v0_2.getQuery();
                                }
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (b == null) {
                    b = "";
                }
            }
            v0_1 = b;
        }
        return v0_1;
    }
}

